package com.lins.common.common.result;

import com.lins.common.common.enums.CodeEnum;
import com.lins.common.common.enums.ExceptionCode;
import com.lins.common.common.enums.SuccessCode;
import lombok.Data;

import java.io.Serializable;

/**
 * @author linsir
 * @title: Head
 * @projectName lins
 * @description: 返回信息头部，基类
 * @date 2021/12/18 11:21
 */

@Data
public class Head implements Serializable {

    /*状态码*/
    private int code;

    /*头部信息*/
    private String msg;

    /*状态*/
    private Boolean state;

    /*基础构造方法*/
    public Head(int code,String msg,Boolean state)
    {
        this.code = code;
        this.msg = msg;
        this.state =state;
    }

    /*基于状态码的构造方法*/
    public Head(CodeEnum codeEnum)
    {
        this.code = codeEnum.getCode();
        this.msg = codeEnum.getMsg();
        this.state = codeEnum.status();
    }

    /*成功*/
    public void success()
    {
        new Head(SuccessCode.SUCCESS);
    }

    /*404*/
    public void Exception404()
    {
        new  Head(ExceptionCode.NOT_FOUND);
    }
}
